package global.com.loansapplication.ui.actviity.user.presenter;

import java.util.List;

import javax.inject.Inject;

import global.com.loansapplication.base.BaseBiz;
import global.com.loansapplication.bean.RechargeSettingInfo;
import global.com.loansapplication.comm.MyApplication;
import global.com.loansapplication.ui.actviity.user.DrawBackAct;
import global.com.loansapplication.ui.actviity.user.biz.RechargeBiz;
import global.com.loansapplication.ui.actviity.user.contract.RechargeContract;

/**
 * Created by Administrator on 2017/10/21.
 */

public class RechargePresenter implements RechargeContract.Presenter {

    RechargeContract.View view;
    RechargeBiz rechargeBiz;


    @Inject
    public RechargePresenter(RechargeContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        rechargeBiz = (RechargeBiz) biz;
    }

    @Override
    public void toDrawBack() {
        view.startAct(DrawBackAct.class, null);
    }


    @Override
    public void selectRecharge(int type) {
        view.updateRecgarge(type);
    }

    @Override
    public void getSetting() {
        view.loading(true);
        rechargeBiz.getRechargeSetting(MyApplication.userInfo.getUserCode(),new BaseBiz.Callback<List<RechargeSettingInfo>>() {
            @Override
            public void onSuccess(List<RechargeSettingInfo> o) {
                if(o.size()>0){
                    o.get(0).setSelected(true);
                    view.updateUI(o);
                }
                view.loading(false);
            }

            @Override
            public void onFailure(List<RechargeSettingInfo> o) {
                view.loading(false);
            }
        });
    }



    @Override
    public void payOrder(String rechargeSettingId, String payMethod) {
    }
}
